package com.test2015.ui.flexiblecomp;

import java.awt.BorderLayout;
import java.awt.Container;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import com.test2015.ui.flexiblecomp.item.FlexibleItem;

public class Test extends JFrame{
	
	public Test(){
		Container contentPane = this.getContentPane();

		JPanel jPanel = new JPanel();
		jPanel.setLayout(new BorderLayout());
		
		contentPane.add(jPanel);
		
		FlexibleComponent flexibleComponent = new FlexibleComponent();
		List<FlexibleItem> items = new ArrayList<FlexibleItem>();
		
		for(int j=0;j<7;j++){
			FlexibleItem fip1 = new FlexibleItem("parent"+j,"c"+j);
			for(int i=0;i<100;i++){
				FlexibleItem tmp = new FlexibleItem(j+"childfor"+i,j+"c"+i);
				fip1.addChild(tmp);
			}
			items.add(fip1);
		}
		
		
		flexibleComponent.setItems(items);
		
		jPanel.add(new JScrollPane(flexibleComponent));
		jPanel.add(flexibleComponent);
		
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setSize(400, 600);
		this.setLocationRelativeTo(null);
		this.setVisible(true);
	}
	
	public static void main(String[] args) {
		new Test();
	}
	
}
